package com.gsnd.briuppts.web.controller;

import com.github.pagehelper.PageInfo;
import com.gsnd.briuppts.Result.Response;
import com.gsnd.briuppts.Result.Result;
import com.gsnd.briuppts.entity.Do.ManagerHurdlesExt;
import com.gsnd.briuppts.service.HurdlesService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/hurdle")
public class HurdleController {
    @Autowired
    HurdlesService hurdlesService;
    @GetMapping("/queryAllMax")
    public Response queryAllMax() {
        return Response.success(hurdlesService.findAllMax());
    }

    @ApiOperation("分⻚多条件查询栏舍信息接⼝")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageNum",value = "当前⻚码",
                    defaultValue = "1", required = true),
            @ApiImplicitParam(name = "pageSize",value = "每⻚⼤⼩",
                    defaultValue = "10", required = true),
            @ApiImplicitParam(name = "hName",value = "栏圈名称"),
            @ApiImplicitParam(name = "hMax",value = "栏圈容量"),
            @ApiImplicitParam(name = "fhName",value = "栏舍名称"),
            @ApiImplicitParam(name = "hEnable",value = "是否可⽤")
    })
    @GetMapping
    public Response queryByConditionsAndPage(Integer pageNum, Integer pageSize,
                                           String hName, Integer hMax, String fhName,
                                           String hEnable) {
        PageInfo<ManagerHurdlesExt> pageInfo =
                hurdlesService.findByPage(pageNum, pageSize, hName, hMax, fhName, hEnable);
        return Response.success(pageInfo);
    }
}
